﻿using System;
using System.Data.Linq.Mapping;
using Purdue.Infrastructure;

namespace Purdue.Models
{
    [Table(Name="AgentInviteCodes")]
    public partial class AgentInviteCode : NotificationObject
    {
        #region Fields
        private Int64 id;
        private string code;
        private string password;
        private string agentCode;
        private Int32 level = 1;
        private DateTime generateTime = DateTime.Now;
        private bool applied = false;
        private DateTime? applyTime;
        #endregion

        #region Properties
        /// <summary>
        /// 编号
        /// </summary>
        [Column(Name = "Id", IsPrimaryKey = true, CanBeNull = false, IsDbGenerated = true, DbType = "BIGINT NOT NULL Identity", AutoSync = AutoSync.OnInsert)]
        public Int64 Id
        {
            get { return id; }
            set
            {
                id = value;
                RaisePropertyChanged(() => Id);
            }
        }

        /// <summary>
        /// 邀请码
        /// </summary>
        [Column]
        public string Code
        {
            get { return code; }
            set
            {
                code = value;
                RaisePropertyChanged(() => Code);
            }
        }

        /// <summary>
        /// 密码
        /// </summary>
        [Column]
        public string Password
        {
            get { return password; }
            set
            {
                password = value;
                RaisePropertyChanged(() => Password);
            }
        }

        /// <summary>
        /// 代理商
        /// </summary>
        [Column]
        public string AgentCode
        {
            get { return agentCode.ToUpper(); }
            set
            {
                agentCode = value;
                RaisePropertyChanged(() => AgentCode);
            }
        }

        /// <summary>
        /// 级别
        /// </summary>
        [Column]
        public Int32 Level
        {
            get { return level; }
            set
            {
                level = value;
                RaisePropertyChanged(() => Level);
            }
        }

        /// <summary>
        /// 生成时间
        /// </summary>
        [Column]
        public DateTime GenerateTime
        {
            get { return generateTime; }
            set
            {
                generateTime = value;
                RaisePropertyChanged(() => GenerateTime);
            }
        }

        /// <summary>
        /// 是否被使用
        /// </summary>
        [Column]
        public bool Applied
        {
            get { return applied; }
            set
            {
                applied = value;
                RaisePropertyChanged(() => Applied);
            }
        }

        /// <summary>
        /// 使用时间
        /// </summary>
        public DateTime? ApplyTime
        {
            get { return applyTime; }
            set
            {
                applyTime = value;
                RaisePropertyChanged(() => ApplyTime);
            }
        }
        #endregion
    }
}
